﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Media;
using System.Diagnostics;
using System.Threading;
using ALDIOrganizer.Properties;

namespace ALDIOrganizer
{
    public partial class MainForm
    {
        private void jobtitle_Format(object sender, ConvertEventArgs e)
        {
            if (e.Value.GetType() == typeof(Int64))
            {
                var i = (Int64)e.Value;
                e.Value = i.To<Position>().ToLongString(); // To<Position> handles any exceptions
            }
            else
            {
                e.Value = String.Empty;
            }
        }

        private void dateBinding_Parse(object sender, ConvertEventArgs e)
        {
            try
            {
                if (e.Value.GetType() == typeof(DateTime))
                {
                    return;
                }
                if (e.Value.GetType() != typeof(string))
                {
                    return;
                }
                var dt = DateTime.Parse(e.Value.ToString());
                e.Value = dt;
            }
            catch { }
        }

        private void btnChangeContract_Click(object sender, EventArgs e)
        {
            ChangeContract();
        }

        /// <remarks>
        /// radio buttons haven't got read-only property.
        /// as the main form is only used for *browsing* (viewing) - not editing (updating)
        /// emps_from_database' details, 
        /// 
        /// </remarks>
        private void rbMale_CheckedChanged(object sender, EventArgs e)
        {
            rbFemale.Checked = !rbMale.Checked;
            rbFemale.Enabled = !rbMale.Checked;
            rbMale.Enabled = rbMale.Checked;
        }
    }
}
